﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spring.Context;

namespace DI
{
    public static class SpringHelper
    {
        /// <summary>
        /// 使用spring创建容器
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <returns></returns>
        public static T GetObject<T>(string name)
        {
            IApplicationContext context = Spring.Context.Support.ContextRegistry.GetContext();
            T t = (T)context.GetObject(name);
            return t;
        }
    }
}
